
//The Element IDs are Declared in the html. I would declare them here but you cannot, they must be in the main doc.
var l1Canvas = document.getElementById("layer1");
l1Canvas.width = 600;
//Temp increase to accomodate map size
l1Canvas.height = 1118;
var l1Context = l1Canvas.getContext("2d");
//document.body.appendChild(canvas);

var l2Canvas = document.getElementById("layer2");
l2Canvas.width = 800;
l2Canvas.height = 800;
var l2Context = l2Canvas.getContext("2d");
//document.body.appendChild(player1Canvas);




var drawList = {

    Img: [],

    add: function (imageName) {

        var loadedImage = new Image();

        loadedImage.src = imageName.toString();

        this.Img[this.Img.length] = loadedImage;

        return (this.Img.length - 1);
    },

    determineContext: function (Layer) {
        switch (Layer) {
            case 1: return l1Context; break;
            case 2: return l2Context; break;

        }
    },

    draw: function (Entity, Layer) {

        this.determineContext(Layer).drawImage(this.Img[Entity.drawID], Entity.x, Entity.y);
    },

    drawAll: function (List,Layer) {
        for (var i = 0; i < List.length; i++)
            this.draw(List[i],Layer);
    },

    drawText: function (Text, x, y, Layer) {
        l1Context.fillText(Text, x, y);
    },


    alreadyExists: function (loadedImage) {
        //Todo, make this work., make sure it loops through all before returning false
        if (loadedImage.src.equals(this.Img[this.Img.length].src))
            alert("Image already exists");
    }


}//End Drawlist

